package top.huntwolf.admin.config;

import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.security.PrivateKey;

@Configuration
public class WxPayConfig {

    /**
     * 获取私钥
     * @return
     */
    @Bean
    public PrivateKey getPrivateKey(){
        PrivateKey merchantPrivateKey = null;
        try {
            merchantPrivateKey = PemUtil.loadPrivateKey(
                    new FileInputStream("./path/to/apiclient_key.pem"));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return merchantPrivateKey;
    }

}
